from variable import *

def copy_ATPreportsbefore():
    #       3.1.3 copy 术前服务报告表格到术前文件夹，编辑后转pdf
    os.chdir(MailWork_path)
    key = "ATP1术前报告模板"
    if os.path.exists(Report_BasicPath):
        print(Report_BasicPath + " exitst")
        for root, dirs, files in os.walk(Report_BasicPath):
            if root == Report_BasicPath:  # 限定在Report_BasicPath下遍历文件
                for file in files:
                    if key in file:
                        print('找到包含"' + key + '"字符的文件,绝对路径为----->' + Report_BasicPath + '/' + file)
                        print('复制到----->' + MailWork_path + "/" + file)
                        src_file = os.path.join(root, file)
                        shutil.copy(src_file, MailWork_path)

    if not os.path.isfile(ServiceReport_NameBefore):
        os.rename(src_file, ServiceReport_NameBefore)

    if os.path.exists(MailWork_path + "/" + "ATP1术前报告模板.xlsx"):
        os.remove(MailWork_path + "/" + "ATP1术前报告模板.xlsx")
        print('移除后术前目录下有文件：%s' % os.listdir(MailWork_path))
    pass